<?php 
class OrderlistModel extends Model{
	public $table="order_list";
	public $validate=array(
	 
	
	);
	
	public function addlist($oid){
		$_POST['oid']=$oid;
		foreach ($_SESSION['cart']['goods'] as $k => $v) {
			$data=array(
			  'quantity'=>$v['num'],
			  'subtotal'=>$v['total'],
			  'glnumber'=>K("GoodsList")->where("glid={$v['id']}")->getField('number'),
			  'order_oid'=>$oid,
			  'goods_gid'=>K("GoodsList")->where("glid={$v['id']}")->getField('goods_gid'),
			  'goodslist_glid'=>$v['id'],
			);
			//减少库存
			
			K("GoodsList")->dec('inventory',"glid={$v['id']}",$v['num']);
			$this->add($data);
			
		}
		unset($_SESSION['cart']);
		
		return true;
	}
}



 ?>